package com.dayang.redbook.auth.controller;

import com.dayang.framework.biz.limiter.aspect.RateLimiter;
import com.dayang.framework.biz.operationlog.aspect.ApiOperationLog;
import com.dayang.framework.common.domain.response.Response;
import com.dayang.redbook.auth.model.user.vo.SendVerificationCodeReqVO;
import com.dayang.redbook.auth.service.VerificationCodeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: dayang
 * @since: 2024/5/23
 * @description:
 */
@RestController
@Slf4j
@Tag(name = "验证码")
public class VerificationCodeController {
    @Resource
    private VerificationCodeService verificationCodeService;

    @Operation(summary = "发送短信验证码")
    @PostMapping("/verification/code/send")
    @ApiOperationLog("发送短信验证码")
    @RateLimiter(time = 60,count = 2)
    public Response<?> send(@Validated @RequestBody SendVerificationCodeReqVO sendVerificationCodeReqVO) {
        return verificationCodeService.send(sendVerificationCodeReqVO);
    }
}
